package fr.axones.pocketagile.ui.components.panel
{
	import mx.core.IVisualElement;
	
	import spark.components.View;

	public class PanelUtil
	{
		public function PanelUtil()
		{
		}
		
		public static function findObject(view:View, type:Class, resultHandler:Function=null):Object
		{
			for (var i:int = 0 ; i < view.numElements ; i++)
			{
				var ve:IVisualElement = view.getElementAt(i);
				
				if(ve is type)
				{
					if((ve as Object).hasOwnProperty("resultHandler") && (ve as Object).resultHandler == resultHandler)
					{
						return ve;
					}
					else if(!(ve as Object).hasOwnProperty("resultHandler"))
					{
						return ve;
					}
				}
			}
			
			return null;
		}
	}
}